var api = require('../../utils/api.js')
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        show:0,
        lists:[],
        count0:0,
        count1:0,
        count2:0,
        user:[]
    },

      //选择分类
      setshow(ret){
        console.log(ret);
        var that=this;
        var i=ret.currentTarget.dataset.i;

        this.setData({
            show:i
        })


      


        this.getmysuqiu();
    },

    addlist(){
        wx.navigateTo({
          url: '/pages/list/apply',
        })
    },

    seeinfo(ret){
        console.log(ret);
        var id=ret.currentTarget.dataset.id;
        var s=ret.currentTarget.dataset.s;
        var level=ret.currentTarget.dataset.level;
        var user=this.data.user;

        if (s==0&&user['level']==level) {
            wx.navigateTo({
                url: '/pages/rets/info?id='+id
              })
        }else{

            wx.navigateTo({
                url: '/pages/rets/infos?id='+id
              })


        }


     
    },

    getnumber(){
        var that=this;
        api.post({
            url: 'usersave/getsuqiunumber',
            data: {},
            success: data => {
                console.log(data.data.coun1) 
                that.setData({
                    count0:data.data.coun0,
                    count1:data.data.coun1,
                    count2:data.data.count2
                })
            }
        })
    },
 
    getmysuqiu(){
        var that=this;
        var status=this.data.show;

        this.setData({
            lists:[]
        })
        api.post({
            url: 'usersave/getmysuqiulist',
            data: {status:status},
            success: data => {
                console.log(data) 

                that.setData({
                    lists:data.data
                })
            }
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onShow(options) {
        var that=this;
        api.post({
            url: 'user/index',
            data: {},
            success: data => {
                console.log(data) 
                that.setData({
                    user:data.data
                })
            }
        })


        this.getmysuqiu();

        this.getnumber();
    },

    previewImage(e) {
        console.log(e);
        var id=e.currentTarget.dataset.i;
        var lists=this.data.lists;
        var imgs=lists[id].imgs;

        wx.previewImage({
            current: imgs[0], // 当前显示图片的http链接
            urls: imgs // 需要预览的图片http链接列表
        });

    },


})